package net.lab1024.sa.admin.module.users.usage.controller;

import net.lab1024.sa.admin.module.users.usage.domain.form.ApprovalFrom;
import net.lab1024.sa.admin.module.users.usage.domain.form.ConsumablesUsageAddForm;
import net.lab1024.sa.admin.module.users.usage.domain.form.ConsumablesUsageQueryForm;
import net.lab1024.sa.admin.module.users.usage.domain.form.ConsumablesUsageUpdateForm;
import net.lab1024.sa.admin.module.users.usage.domain.vo.ConsumablesUsageVO;
import net.lab1024.sa.admin.module.users.usage.service.ConsumablesUsageService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 实训室耗材领用 Controller
 *
 * @Author 李韵妍
 * @Date 2024-11-08 13:31:03
 * @Copyright 🐂🐎bloc
 */

@RestController
@Tag(name = "实训室耗材领用")
public class ConsumablesUsageController {

    @Resource
    private ConsumablesUsageService consumablesUsageService;

    @Operation(summary = "分页查询 @author 李韵妍")
    @PostMapping("/consumablesUsage/queryPage")
    @SaCheckPermission("consumablesUsage:query")
    public ResponseDTO<PageResult<ConsumablesUsageVO>> queryPage(@RequestBody @Valid ConsumablesUsageQueryForm queryForm) {
        return ResponseDTO.ok(consumablesUsageService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 李韵妍")
    @PostMapping("/consumablesUsage/add")
    @SaCheckPermission("consumablesUsage:add")
    public ResponseDTO<String> add(@RequestBody @Valid ConsumablesUsageAddForm addForm) {
        return consumablesUsageService.add(addForm);
    }

    @Operation(summary = "更新 @author 李韵妍")
    @PostMapping("/consumablesUsage/update")
    @SaCheckPermission("consumablesUsage:update")
    public ResponseDTO<String> update(@RequestBody @Valid ConsumablesUsageUpdateForm updateForm) {
        return consumablesUsageService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 李韵妍")
    @PostMapping("/consumablesUsage/batchDelete")
    @SaCheckPermission("consumablesUsage:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return consumablesUsageService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 李韵妍")
    @GetMapping("/consumablesUsage/delete/{id}")
    @SaCheckPermission("consumablesUsage:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return consumablesUsageService.delete(id);
    }

    @Operation(summary = "审批 @author 李韵妍")
    @PostMapping("/consumablesUsage/approval")
    @SaCheckPermission("consumablesUsage:approval")
    public ResponseDTO<String> approval(@RequestBody @Valid ApprovalFrom updateForm) {
        return consumablesUsageService.approval(updateForm);
    }
}
